package dcedit.util;

// Import Java SDK Classes
import java.io.File;
import java.io.InputStream;
import javax.swing.JLabel;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.imageio.ImageIO;
import javax.imageio.stream.ImageInputStream;
import java.net.URL;

/** OmniImage class */
public class OmniImage extends JLabel {
    /** Serializable constant */
   public static final long serialVersionUID = 1289514881014L;

   /** Constructor */
   public OmniImage(String img) {
      this(new File(img));
   } // END constructor

   /** Constructor */
   public OmniImage(File img) {
      try {
         if(null != img) {
            this.setIcon(new ImageIcon(ImageIO.read(img)));
         } // END if
      } catch(Exception e) {}
   } // END constructor

   /** Constructor */
   public OmniImage(InputStream img) {
      try {
         if(null != img) {
            this.setIcon(new ImageIcon(ImageIO.read(img)));
         } // END if
      } catch(Exception e) {}
   } // END constructor

   /** Constructor */
   public OmniImage(ImageInputStream img) {
      try {
         if(null != img) {
            this.setIcon(new ImageIcon(ImageIO.read(img)));
         } // END if
      } catch(Exception e) {}
   } // END constructor

   /** Constructor */
   public OmniImage(URL img) {
      try {
         if(null != img) {
            this.setIcon(new ImageIcon(ImageIO.read(img)));
         } // END if
      } catch(Exception e) {}
   } // END constructor

   /** getIcon method */
   public static Icon toIcon(String img) {
      OmniImage tmpImg = new OmniImage(img);
      return tmpImg.getIcon();
   } // END getIcon

   /** getIcon method */
   public static Icon toIcon(File img) {
      OmniImage tmpImg = new OmniImage(img);
      return tmpImg.getIcon();
   } // END getIcon

   /** getIcon method */
   public static Icon toIcon(InputStream img) {
      OmniImage tmpImg = new OmniImage(img);
      return tmpImg.getIcon();
   } // END getIcon

   /** getIcon method */
   public static Icon toIcon(ImageInputStream img) {
      OmniImage tmpImg = new OmniImage(img);
      return tmpImg.getIcon();
   } // END getIcon

   /** getIcon method */
   public static Icon toIcon(URL img) {
      OmniImage tmpImg = new OmniImage(img);
      return tmpImg.getIcon();
   } // END getIcon
} // END class OmniImage